﻿using System;
using System.Windows.Forms;

namespace TextEditor
{
    

    public class A_InsertExDataInput : A_Action
    {
        public A_InsertExDataInput()
        {
            base.HotKey = Keys.Control | Keys.J;
        }

        public override string ActionName()
        {
            return "insertexdatainput";
        }

        public override bool Execute()
        {
            ZYTextElement preElement = base.myOwnerDocument.Content.PreElement;
            ZYTextSelect parent = preElement as ZYTextSelect;
            if (parent == null)
            {
                parent = preElement.Parent as ZYTextSelect;
            }
            if (parent != null)
            {
                ZYTextInput input = base.myOwnerDocument._InsertInput(parent.ID + "_data", parent.Text + " 的说明");
            }
            return true;
        }

        public override bool isEnable()
        {
            if (base.myOwnerDocument.CanModify())
            {
                ZYTextElement preElement = base.myOwnerDocument.Content.PreElement;
                if (preElement == null)
                {
                    return false;
                }
                if ((preElement is ZYTextSelect) || (preElement.Parent is ZYTextSelect))
                {
                    return base.isEnable();
                }
            }
            return false;
        }
    }
}

